package cc;

//定义一个抽象的动物类
abstract class Animals {
 protected String name;   //名字
 protected String species;  //种类
 protected String breed;	//品种
 protected double price;	//价格

 public Animals(String name, String species, String breed, double price) {
     this.name = name;
     this.species = species;
     this.breed = breed;
     this.price = price;
 }

 public void eat() {
     System.out.println(name + " 正在吃饭。");
 }

 public void sleep() {
     System.out.println(name + " 正在睡觉。");
 }

 // 抽象方法，需要在子类中实现
 public abstract void play();

 // 抽象方法，需要在子类中实现
 public abstract void makeSound();
	// 抽象方法，需要在子类中实现
 public abstract void z();
}

//定义小猫类
class Cat extends Animals {
 public Cat(String name, String species, String breed, double price) {
     super(name, species, breed, price);
 }

 @Override
 public void play() {
     System.out.println(name +" 正在玩，并且发出喵喵的叫声。");
     makeSound();
 }

 @Override
 public void makeSound() {
     System.out.println(name + " 喵喵叫。");
 }
 
 @Override
 public void z() {
     System.out.println(name + "是一只" + breed + " 价格为"+price + "元");
 }
}



//定义小狗类
class Dog extends Animals {
 public Dog(String name, String species, String breed, double price) {
     super(name, species, breed, price);
 }

 @Override
 public void play() {
     System.out.println(name + " 正在玩。");
 }

 @Override
 public void makeSound() {
     System.out.println(name + " 汪汪叫。");
 }

@Override
public void z() {
	System.out.println(name + "是一只" + breed + " 价格为"+price + "元");
	
}
}

//测试类
public class Animal {
 public static void main(String[] args) {
     // 实例化对象
     Animals cat1 = new Cat("小花", "猫", "波斯猫", 1500.0);
     Animals cat2 = new Cat("小黑", "猫", "英国短毛猫", 2000.0);

     Animals dog1 = new Dog("小白", "狗", "金毛", 3000.0);
     Animals dog2 = new Dog("大黄", "狗", "哈士奇", 2500.0);

     // 测试对象的方法
     cat1.eat();
     cat1.sleep();
     cat1.play();
     cat1.z();

     dog1.eat();
     dog2.eat();
     dog1.sleep();
     dog1.play();
     dog1.makeSound();
     dog1.z();
 }
}
